#pragma once

#include "BasicType.h"
#include "Shape.h"

namespace LightPlayer{

	typedef array< vec2 > Vector2dVector;

	class Triangulate
	{
	public:

		// triangulate a contour/polygon, places results in array
		// as series of triangles.
		static bool Process(const Vector2dVector &contour, Vector2dVector &result);
		static bool ProcessP2T(const Path &contour, Vector2dVector &result);

		// compute area of a contour/polygon
		static float Area(const Vector2dVector &contour);

		// compute Bounds of a contour/polygon
		static void Bounds(const Vector2dVector &contour, vec2& o_min, vec2& o_max );

		// decide if point Px/Py is inside triangle defined by
		// (Ax,Ay) (Bx,By) (Cx,Cy)
		static bool InsideTriangle(float Ax, float Ay,
			float Bx, float By,
			float Cx, float Cy,
			float Px, float Py);


	private:
		static bool Snip(const Vector2dVector &contour,int u,int v,int w,int n,int *V);

	};


};

